<template>
    <div class='home'>
        <van-sticky>
        <van-tabs v-model="active" @click="change()">
            <van-tab v-for="item in homecate" :key="item._id" :title="item.title" :name="item._id">               
            </van-tab>
        </van-tabs>
        </van-sticky>
        <hr>
        
        <homelist :homelist="gethome"></homelist>
    </div>
</template>

<script>
import homelist from "../../components/homelist"
    export default {
        data() {
            return {
                active:0,
                homecate:[],
                homelist:[],
                gethome:[],
            };
        },
        components:{
            homelist,
        },
        mounted() {
            this.$http("fenlei.json","get").then((res)=>{
                console.log(res)
                this.homecate = res.result
            });
            this.$http("list.json","get").then((res)=>{
                console.log(res)
                this.homelist = res.result
                this.change()
            })
        },
        methods: {
            change(){
                this.gethome = this.homelist.filter((item)=>{
                    return item.cid == this.active
                })
            },
            
        },
    };
</script>

<style lang='scss'>

</style>